package com.sys.gradepaysys.controller.event;

import com.alibaba.fastjson.JSON;
import com.sys.gradepaysys.dao.BaseDao;
import com.sys.gradepaysys.entity.ResultData;
import com.sys.gradepaysys.service.EventService;
import com.sys.gradepaysys.service.EventServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "getEventStu", value = "/getEventStu")
public class getEventStu extends HttpServlet {
    private EventService eventService = new EventServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String sid = request.getParameter("sid");
        String eid = request.getParameter("eid");
        String sql="select  stu.*,spt.*  from student stu right join(select e.*,sp.eid,sp.pdate,sp.sid,sp.pay from  event e RIGHT join spay sp on e.e_id=sp.eid) spt on spt.sid=stu.s_id where e_id=?";
        String arr[]={eid};
        List<Map<String, String>> maps = BaseDao.selectList(sql,arr);
        String s = "";
        s = JSON.toJSONString(new ResultData<>(200, null, maps));
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(s);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
